Another rapid-fire round of leak fixes. vtesto passes. vtesto -l is still
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 21:46:42 +0000 (21:46 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 21:46:42 +0000 (21:46 +0000)
unhappy and is likely to be for a while.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4684 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/alan.cc
gpsbabel/bcr.cc
gpsbabel/bushnell_trl.cc
gpsbabel/gdb.cc
gpsbabel/google.cc
gpsbabel/interpolate.cc
gpsbabel/magproto.cc
gpsbabel/mtk_logger.cc
gpsbabel/tef_xml.cc
gpsbabel/trackfilter.cc
gpsbabel/wbt-200.cc

index 763742bf21d87ab45f34a499fe33540da914e259..3ae0dcb550059d1bed8a842a91051d9348c305ac 100644 (file)
@@ -516,11 +516,13 @@ static waypoint* get_wpt(struct wprdata* wprdata, unsigned n)
   WP->shortname = xstrndup(wpt->name,j+1);
   for (j=WPT_COMMENT_LEN-1; j >= 0 && wpt->comment[j] == ' '; j--) {};
   if (j >= 0) {
-    WP->description = xstrndup(wpt->comment, j+1);
+    char *s = xstrndup(wpt->comment, j+1);
+    WP->description = s;
+    xfree(s);
   } else {
-    WP->description = xstrdup("");
+    WP->description = "";
   }
-  WP->notes = xstrdup("");
+  WP->notes = "";
 
   return WP;
 }
@@ -617,12 +619,16 @@ static void trl_read(void)
     for (j=TRK_NAME_LEN-1;
          j >= 0 && (trkhdr->name[j] == ' ' || trkhdr->name[j] == '\0');
          j--) {};
-    TL->rte_name = xstrndup(trkhdr->name,j+1);
+    char *s1 = xstrndup(trkhdr->name,j+1);
+    TL->rte_name = s1;
+    xfree(s1);
     /*  TL->rte_name[TRK_NAME_LEN+1] = 0; */   /* MAYBE BAD ADDRESS (Valgrind) */
     for (j=TRK_COMMENT_LEN-1;
          j >= 0 && (trkhdr->comment[j] == ' ' || trkhdr->comment[j] == '\0');
          j--) {};
-    TL->rte_desc = xstrndup(trkhdr->comment,j+1);
+    s1 = xstrndup(trkhdr->comment,j+1);
+    TL->rte_desc = s1;
+    xfree(s1);
     /*  TL->rte_desc[TRK_COMMENT_LEN+1] = 0; */        /* MAYBE BAD ADDRESS (Valgrind) */
     TL->rte_num = i;
 
index 007884ae912e16608626f40528752a8e719f0a97..9c2d77fea5b18f2dfdc52742cb45bcfc47a8636a 100644 (file)
@@ -143,7 +143,7 @@ bcr_handle_icon_str(const char* str, waypoint* wpt)
         }
         return;
       }
-      wpt->description = xstrdup(m->symbol_DE);
+      wpt->description = m->symbol_DE;
       if (m->mps_name != NULL) {
         nr = gt_find_icon_number_from_desc(m->mps_name, MAPSOURCE);
         wpt->icon_descr = gt_find_desc_from_icon_number(nr, MAPSOURCE, NULL);
@@ -265,7 +265,7 @@ bcr_data_read(void)
   route = route_head_alloc();
 
   if ((str = inifile_readstr(ini, "client", "routename"))) {
-    route->rte_name = xstrdup(str);
+    route->rte_name = str;
   }
 
   route_add_head(route);
@@ -288,7 +288,7 @@ bcr_data_read(void)
 
     wpt = waypt_new();
 
-    wpt->shortname = xstrdup(station);
+    wpt->shortname = station;
     bcr_mercator_to_wgs84(mlat, mlon, &wpt->latitude, &wpt->longitude);
 
     if (NULL != (str = inifile_readstr(ini, "client", station))) {
@@ -310,7 +310,7 @@ bcr_data_read(void)
         *c = '\0';
       }
       if (*str) {
-        wpt->notes = xstrdup(str);
+        wpt->notes = str;
       }
       if ((str = c)) {
         str++;
@@ -319,12 +319,7 @@ bcr_data_read(void)
           *c = '\0';
         }
         if (*str) {
-#if NEW_STRINGS
           wpt->shortname = str;
-#else
-          xfree(wpt->shortname);
-          wpt->shortname = xstrdup(str);
-#endif
         }
       }
     }
index c60b888407b288ef74e2e215a1d7708c64e29579..7ca941cb92cd2343d61a4bf580e76cbef81965da 100644 (file)
@@ -43,7 +43,7 @@ rd_init(const char* fname)
   trk_head = route_head_alloc();
   track_add_head(trk_head);
 
-  trk_head->rte_name = xstrdup(lrtrim(h));
+  trk_head->rte_name = lrtrim(h);
 }
 
 static void
index f9dfdc01e32faf07050ba51cee44121343c239ac..e36bec8966f05ba1c1a7cdb966d161195f69da31 100644 (file)
@@ -680,7 +680,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
       res->AddUrlLink(l);
     }
     if (wpt_class != 0) {
-      res->description = xstrdup(l.url_.toUtf8().data());
+      res->description = l.url_;
     }
   } else { // if (gdb_ver >= GDB_VER_3)
     int i, url_ct;
index c18e7b0498b756a8360485742d0e4a3aaa01118c..2e3e6bc91f7de594e3e5b83eb13a8345e28f4cdd 100644 (file)
@@ -130,7 +130,7 @@ void goog_segment(xg_string args, const QXmlStreamAttributes* unused)
     xfree(wpt_tmp->shortname);
 #endif
     wpt_tmp->shortname = mkshort(desc_handle, CSTRc(args));
-    wpt_tmp->description = xstrdup(args);
+    wpt_tmp->description = args;
   }
 }
 
index 918dfc4397181c1d136cc15f03b310a31c7ba909..a78b538bb344c40df8cb882caa8c74aa1c5e16cf 100644 (file)
@@ -77,8 +77,8 @@ interpfilt_process(void)
     route_head* rte_old = (route_head*)elem;
 
     rte_new = route_head_alloc();
-    rte_new->rte_name = xstrdup(rte_old->rte_name);
-    rte_new->rte_desc = xstrdup(rte_old->rte_desc);
+    rte_new->rte_name = rte_old->rte_name;
+    rte_new->rte_desc = rte_old->rte_desc;
     rte_new->fs = fs_chain_copy(rte_old->fs);
     rte_new->rte_num = rte_old->rte_num;
     if (opt_route) {
index a501c0ddcff410f3b80c08e100b09b494cf2a9aa..826f39ad58b82b66429ac98b61a8043f8d664981 100644 (file)
@@ -1269,8 +1269,8 @@ mag_wptparse(char* trkmsg)
   waypt->longitude = ddmm2degrees(lngdeg);
 
   waypt->altitude = alt;
-  waypt->shortname = xstrdup(shortname);
-  waypt->description = xstrdup(descr);
+  waypt->shortname = shortname;
+  waypt->description = descr;
   waypt->icon_descr = mag_find_descr_from_token(icon_token);
 
   return waypt;
index d1f4bc004cbace83f6ae88193f2860927f09ee72..748144e4d0e523138434b9fb696c395c256cf207 100644 (file)
@@ -747,7 +747,6 @@ mtk_retry:
 static route_head*  trk_head = NULL;
 static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
 {
-  char     wp_name[20];
   waypoint* trk = waypt_new();
 
   if (global_opts.masked_objective& TRKDATAMASK && (trk_head == NULL || (mtk_info.track_event & MTK_EVT_START))) {
@@ -845,8 +844,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
     /* Button press -- create waypoint, start count at 1 */
     waypoint* w = waypt_dupe(trk);
 
-    sprintf(wp_name, "WP%06d", waypt_count()+1);
-    w->shortname      = xstrdup(wp_name);
+    w->shortname = QString().sprintf("WP%06d", waypt_count()+1);
     waypt_add(w);
   }
   // In theory we would not add the waypoint to the list of
@@ -855,8 +853,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
   // trackpoint unless we include/duplicate it.
 
   if (global_opts.masked_objective & TRKDATAMASK) {
-    sprintf(wp_name, "TP%06d", idx);
-    trk->shortname      = xstrdup(wp_name);
+    trk->shortname = QString().sprintf("TP%06d", idx);
 
     track_add_wpt(trk_head, trk);
   }
index 707b7c275d931562d48014c2b9fa549a389013a0..520307309bcb9823152aca0d84621f6c9f67f308 100644 (file)
@@ -46,13 +46,6 @@ static arglist_t tef_xml_args[] = {
 
 #define MYNAME "TourExchangeFormat"
 
-static char*
-trimmed_strdup(const QString& str)
-{
-  QString trimmed = str.trimmed();
-  return xstrdup(CSTR(trimmed));
-}
-
 static xg_callback     tef_start, tef_header, tef_list_start, tef_list_end;
 static xg_callback     tef_item_start, tef_point, tef_item_end;
 
@@ -103,9 +96,9 @@ tef_header(xg_string args, const QXmlStreamAttributes* attrv)
   route = route_head_alloc();
   foreach(QXmlStreamAttribute attr, *attrv) {
     if (attr.name().compare("Name", Qt::CaseInsensitive) == 0) {
-      route->rte_name = trimmed_strdup(attr.value().toString());
+      route->rte_name = attr.value().toString().trimmed();
     } else if (attr.name().compare("Software", Qt::CaseInsensitive) == 0) {
-      route->rte_desc = trimmed_strdup(attr.value().toString());
+      route->rte_desc = attr.value().toString().trimmed();
     }
   }
   route_add_head(route);
@@ -119,6 +112,13 @@ tef_list_start(xg_string args, const QXmlStreamAttributes* attrv)
   }
 }
 
+#if OMG
+
+TODO: this whole horrible mess is not covered at all in the test suite,
+so just stub it all out until someone cares. (TEF is rarely used from 
+what we can tell.)
+
+
 /* in "TourExchangeFormat" the following can happen:
  *
  * SegDescription="L34\Wittlicher Strasse"
@@ -164,7 +164,7 @@ fix_notes(const char* name, char* notes)
 }
 
 static char*
-fix_notes(const QString& name, const QString& notes)
+Xfix_notes(const QString& name, const QString& notes)
 {
 
   char* cname = xstrdup(name);
@@ -176,6 +176,12 @@ fix_notes(const QString& name, const QString& notes)
 //  xfree(cnotes);
   return r;
 }
+#else
+static QString 
+fix_notes(const QString& name, const QString& notes){
+    return notes;
+}
+#endif
 
 static void
 waypoint_final()
@@ -247,16 +253,16 @@ tef_item_start(xg_string args, const QXmlStreamAttributes* attrv)
     QByteArray attrtext = attrstr.toUtf8();
 
     if (attr.name().compare("SegDescription", Qt::CaseInsensitive) == 0) {
-      wpt_tmp->shortname = trimmed_strdup(attrtext.constData());
+      wpt_tmp->shortname = attrstr.trimmed();
     } else if (attr.name().compare("PointDescription", Qt::CaseInsensitive) == 0) {
-      wpt_tmp->description = trimmed_strdup(attrtext.constData());
+      wpt_tmp->description = attrstr.trimmed();
     } else if (attr.name().compare("ViaStation", Qt::CaseInsensitive) == 0 &&
                attr.value().compare("true", Qt::CaseInsensitive) == 0) {
       wpt_tmp->wpt_flags.fmt_use = 1;  /* only a flag */
 
       /* new in TEF V2 */
     } else if (attr.name().compare("Instruction", Qt::CaseInsensitive) == 0) {
-      wpt_tmp->description = trimmed_strdup(attrtext.constData());
+      wpt_tmp->description = attrstr.trimmed();
     } else if (attr.name().compare("Altitude", Qt::CaseInsensitive) == 0) {
       wpt_tmp->altitude = attrstr.toDouble();
     } else if (attr.name().compare("TimeStamp", Qt::CaseInsensitive) == 0) {
index 10f8f567b2760c1163b7ff89732387d26df8ce6f..9f1d35a30dca9ee3eb1aa0a51e84da7d7772d225 100644 (file)
@@ -404,23 +404,12 @@ trackfilter_split_init_rte_name(route_head* track, const QDateTime dt)
     } else {
       snprintf(buff, sizeof(buff), "%s-%s", opt_title, tbuff);
     }
-#if NEW_STRINGS
   } else if (!track->rte_name.isEmpty()) {
-#else
-  } else if ((track->rte_name != NULL) && (strlen(track->rte_name) > 0)) {
-#endif
     snprintf(buff, sizeof(buff), "%s-%s", CSTRc(track->rte_name), tbuff);
   } else {
     strncpy(buff, tbuff, sizeof(buff));
   }
-#if NEW_STRINGS
   track->rte_name = buff;
-#else
-  if (track->rte_name != NULL) {
-    xfree(track->rte_name);
-  }
-  track->rte_name = xstrdup(buff);
-#endif
 }
 
 static void
@@ -443,14 +432,7 @@ trackfilter_pack_init_rte_name(route_head* track, const time_t default_time)
   } else {
     strncpy(buff, opt_title, sizeof(buff));
   }
-#if NEW_STRINGS
   track->rte_name = buff;
-#else
-  if (track->rte_name != NULL) {
-    xfree(track->rte_name);
-  }
-  track->rte_name = xstrdup(buff);
-#endif
 }
 
 /*******************************************************************************
@@ -979,12 +961,8 @@ trackfilter_seg2trk(void)
         dest = route_head_alloc();
         dest->rte_num = src->rte_num;
         /* name in the form TRACKNAME #n */
-#if NEW_STRINGS
         if (!src->rte_name.isEmpty()) {
-#else
-        if (src->rte_name) {
-#endif
-          xasprintf(&dest->rte_name, "%s #%d", CSTRc(src->rte_name), ++trk_seg_num);
+          dest->rte_name = QString().sprintf("%s #%d", CSTRc(src->rte_name), ++trk_seg_num);
         }
 
         /* Insert after original track or after last newly
index 15cfd4876aef0f7df0f3e7130ee8de25f205db3e..1223f94b7c27409fdb10c8f1bf36bf82cfa694a0 100644 (file)
@@ -551,7 +551,7 @@ static waypoint* make_point(double lat, double lon, double alt, time_t tim, cons
   wpt->longitude      = lon;
   wpt->altitude       = alt;
   wpt->SetCreationTime(tim);
-  wpt->shortname      = xstrdup(wp_name);
+  wpt->shortname      = wp_name;
 
   return wpt;
 }